<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en" class="no-js" id="ng-app">
<head>
<meta charset="UTF-8">
<jsp:include page="/includes/common/head.jsp" />
<title>CS4280 BOOKSTORE</title>
</head>
<body>
	<div data-flex-background-src="${ baseURL }/assets/img/background.jpg" flex-background></div>
	<jsp:include page="/includes/header.jsp">
   		<jsp:param name="currentUser" value="${currentUser}" /><jsp:param name="baseURL" value="${ baseURL }" />
	</jsp:include>
	<section id="mainContent">
		<jsp:include page="/includes/admin/sidebar.jsp" />
		
		<section class="content">
		<c:if test="${action == 'new'}">
			<form action="${ baseURL }/admin/manage/book?action=new" method="post">
				<ul>
					<li><label>Title</label><input type="text" name="title" required="required" /></li>
					<li><label>Description</label><textarea name="description" required="required"></textarea></li>
					<li><label>Price</label><input type="text" name="price" required="required" /></li>
					<li><label>Quantity</label><input type="text" name="quantity" required="required" /></li>
					<li><label>Publisher</label><input type="text" name="publisher" required="required" /></li>
					<li><label>Language</label><input type="text" name="language" required="required" /></li>
				</ul>
				<input type="hidden" name="submit" value="true" />
				<input type="submit" value="Submit"/>
			</form>
		</c:if>
		
		<c:if test="${action == 'failed'}">
			<form action="${ baseURL }/admin/manage/book?action=new" method="post">
				<c:if test="${isQuantityNotInt}">
					<span class="form-error">Quantity is not a integer. Please try again.</span><br />
				</c:if>
				<c:if test="${isPriceNotFloat}">
					<span class="form-error">Price is not a decimal number. Please try again.</span><br />
				</c:if>
				
				<ul>
					<li><label>Title</label><input type="text" name="title" required="required" value="${ book.title }" /></li>
					<li><label>Description</label><textarea name="description" required="required">${ book.description }</textarea></li>
					<li><label>Price</label><input type="text" name="price" required="required" value="${ book.price }" /></li>
					<li><label>Quantity</label><input type="text" name="quantity" required="required" value="${ book.quantity }" /></li>
					<li><label>Publisher</label><input type="text" name="publisher" required="required" value="${ book.publisher }" /></li>
					<li><label>Language</label><input type="text" name="language" required="required" value="${ book.language }" /></li>
				</ul>
				<input type="hidden" name="submit" value="true" />
				<input type="submit" value="Submit"/>
			</form>
		</c:if>
		</section>
	</section>
</body>
</html>
